<template>
  <div>
    <Header :back="true"></Header>
    <van-tabs>
      <van-tab v-for="item in tabs" :title="item.date" :key="item.date">
        <!-- 资产负债表 -->
        <van-tabs type="card" style="margin-top:1rem" v-if="active=='asset'">
          <van-tab title="资产">
            <div class="th">
              <div class="td1">发生日期</div>
              <div class="td3">资产类型</div>
              <div class="td4" style="text-align:center">金额</div>
              <div class="td2">类型</div>
            </div>
            <div class="tr">
              <div class="td1">{{item.date}}</div>
              <div class="td3">房屋建筑</div>
              <div class="td4">900000.00</div>
              <div class="td2">销项</div>
            </div>
            <div class="tr">
              <div class="td1">{{item.date}}</div>
              <div class="td3">房屋建筑</div>
              <div class="td4">190050.00</div>
              <div class="td2">银行对账单</div>
            </div>
          </van-tab>
          <van-tab title="负债">{{item.date}}负债</van-tab>
        </van-tabs>
        <!-- 利润表 -->
        <van-tabs type="card" style="margin-top:1rem" v-if="active=='profit'">
          <van-tab title="利润表">{{item.date}}利润表</van-tab>
        </van-tabs>
        <!-- 报税信息 -->
        <van-tabs type="card" style="margin-top:1rem" v-if="active=='info'">
          <van-tab title="已报税">{{item.date}}报税表</van-tab>
        </van-tabs>
        <!-- 缺失资料明细 -->
        <van-tabs type="card" style="margin-top:1rem" v-if="active=='data'">
          <van-tab title="缺失资料明细">
            <div class="th">
              <div class="td1">发生日期</div>
              <div class="td3">票据号码</div>
              <div class="td4">金额</div>
              <div class="td2">类型</div>
            </div>
            <div class="tr">
              <div class="td1">{{item.date}}</div>
              <div class="td3">4356767 - 78345245</div>
              <div class="td4">9000.00</div>
              <div class="td2">销项</div>
            </div>
            <div class="tr">
              <div class="td1">{{item.date}}</div>
              <div class="td3">4356767 - 78345245</div>
              <div class="td4">9000.00</div>
              <div class="td2">银行对账单</div>
            </div>
          </van-tab>
        </van-tabs>
      </van-tab>
    </van-tabs>

    <van-tabbar v-model="active" active-color="#07c160">
      <van-tabbar-item name="asset" icon="gold-coin-o">资产负债</van-tabbar-item>
      <van-tabbar-item name="profit" icon="balance-o">利润</van-tabbar-item>
      <van-tabbar-item name="info" icon="description">报税信息</van-tabbar-item>
      <van-tabbar-item name="data" icon="records">缺失资料</van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
import Header from "@/components/header";
export default {
  components: {
    Header,
  },
  data() {
    return {
      tabs: [
        {
          date: "2020-12",
          sheet: [],
        },
        {
          date: "2021-01",
          sheet: [],
        },
        {
          date: "2021-02",
          sheet: [],
        },
        {
          date: "2021-03",
          sheet: [],
        },
        {
          date: "2021-04",
          sheet: [],
        },
        {
          date: "2021-05",
          sheet: [],
        },
        {
          date: "2021-06",
          sheet: [],
        },
        {
          date: "2021-07",
          sheet: [],
        },
      ],
      active: "asset",
      loading: false,
      finished: false,
      dataList: [],
    };
  },
  methods: {
    onLoad() {
      // 异步更新数据
      // setTimeout 仅做示例，真实场景中一般为 ajax 请求
      setTimeout(() => {
        for (let i = 0; i < 10; i++) {
          this.dataList.push(this.dataList.length + 1);
        }

        // 加载状态结束
        this.loading = false;

        // 数据全部加载完成
        if (this.dataList.length >= 40) {
          this.finished = true;
        }
      }, 1000);
    },
  },
};
</script>

<style lang="less" scoped>
/deep/.van-tabs__line {
  position: absolute;
  bottom: 15px;
  left: 0;
  z-index: 1;
  width: 50px;
  height: 3px;
  background-color: #07c160;
  border-radius: 3px;
}

/deep/.van-tabs__nav--card {
  margin: 0;
  border-top: 1px solid #07c160;
  border-bottom: 1px solid #07c160;
  border-left: 1px solid #07c160;
  border-right: 0 solid #000;
}

/deep/.van-tabs__nav--card .van-tab.van-tab--active {
  background-color: #07c160;
}

/deep/.van-tabs__nav--card .van-tab {
  border-right: 1px solid #07c160;
  color: #07c160;
}

/deep/.van-tab__pane,
.van-tab__pane-wrapper {
  width: 96vw;
  margin: auto;
}
/deep/.van-tabs__nav--card .van-tab.van-tab--active {
  color: #fff;
}
.th {
  margin-top: 1rem !important;
  border-bottom: 0 solid #000 !important;
  font-weight: bold;
}
.th,
.tr {
  display: flex;
  border: 1px solid #eee;
  height: 3rem;
  line-height: 3rem;
  text-align: center;
  width: 98vw;
  margin: auto;
  .td3 {
    flex: 1.5;
    border-right: 1px solid #eee;
    font-size: 12px;
  }
  .td4 {
    flex: 0.7;
    border-right: 1px solid #eee;
    font-size: 12px;
    text-align: right;
  }
  .td1 {
    flex: 0.7;
    border-right: 1px solid #eee;
    font-size: 12px;
  }
  .td2 {
    flex: 0.8;
    border-right: none;
    font-size: 12px;
  }
}
</style>